#include "stdafx.h"
#include "H264VideoLiveServerMediaSubsession.h"

#include "ByteStreamFileSource.hh"
#include "H264VideoStreamFramer.hh"
#include "ByteStreamLiveSource.h"

H264VideoLiveServerMediaSubsession*
H264VideoLiveServerMediaSubsession::createNew(UsageEnvironment& env,
char const* fileName,
Boolean reuseFirstSource)
{
	return new H264VideoLiveServerMediaSubsession(env, fileName, reuseFirstSource);
}

H264VideoLiveServerMediaSubsession::H264VideoLiveServerMediaSubsession(UsageEnvironment& env, char const* fileName, Boolean reuseFirstSource)
	: H264VideoFileServerMediaSubsession(env, fileName, reuseFirstSource)
{
	strcpy(fFileName, fileName);
}


H264VideoLiveServerMediaSubsession::~H264VideoLiveServerMediaSubsession()
{
}

FramedSource* H264VideoLiveServerMediaSubsession::createNewStreamSource(unsigned clientSessionId, unsigned& estBitrate)
{
	/* Remain to do : assign estBitrate */
	estBitrate = 1000; // kbps, estimate

	// Create the video source:
	ByteStreamLiveSource* liveSource = ByteStreamLiveSource::createNew(envir(), fFileName);
	//ByteStreamFileSource* liveSource = ByteStreamFileSource::createNew(envir(), fFileName);
	if (liveSource == NULL)
	{
		return NULL;
	}

	// Create a framer for the Video Elementary Stream:
	return H264VideoStreamFramer::createNew(envir(), liveSource);
}